<template>
  <div>
    <!--预览界面 -->
    <a-form-item
      :required="widget.options.required"
      :label="widget.name"
      :name="widget.table + '-' + widget.field"
    >
      <template v-if="widget.type == 'input'">
        <Finput :setting="widget" :models="models"></Finput>
      </template>
      <template v-if="widget.type == 'select'">
        <Fselect :setting="widget" :models="models"></Fselect>
      </template>
      <template v-if="widget.type == 'date'">
        <Fdate :setting="widget" :models="models"></Fdate>
      </template>
      <template v-if="widget.type == 'number'">
        <Fnumber :setting="widget" :models="models"></Fnumber>
      </template>
      <template v-if="widget.type == 'radio'">
        <Fradio :setting="widget" :models="models"></Fradio>
      </template>
      <template v-if="widget.type == 'checkbox'">
        <Fcheckbox :setting="widget" :models="models"></Fcheckbox>
      </template>
      <template v-if="widget.type == 'rate'">
        <Frate :setting="widget" :models="models"></Frate>
      </template>
      <template v-if="widget.type == 'switch'">
        <Fswitch :setting="widget" :models="models"></Fswitch>
      </template>
      <template v-if="widget.type == 'slider'">
        <Fslider :setting="widget" :models="models"></Fslider>
      </template>
      <template v-if="widget.type == 'text'">
        {{ models[widget.table + '-' + widget.field] }}
      </template>
      <template v-if="widget.type == 'imgupload'">
        <FuploadImg :setting="widget" :models="models"></FuploadImg>
      </template>
      <template v-if="widget.type == 'fileupload'">
        <FuploadFile :setting="widget" :models="models"></FuploadFile>
      </template>
      <template v-if="widget.type == 'table'">
        <ftable :setting="widget" :models="models"></ftable>
      </template>
    </a-form-item>
  </div>
</template>

<script>
  import {
    Finput,
    Fdate,
    Fselect,
    Fnumber,
    Fradio,
    Fcheckbox,
    Frate,
    Fswitch,
    Fslider,
    FuploadImg,
    FuploadFile,
    Ftable,
  } from './formComponents/index'

  export default {
    // eslint-disable-next-line vue/require-prop-types
    props: ['widget', 'models', 'tablename', 'formdata'],
    components: {
      Finput,
      Fdate,
      Fselect,
      Fnumber,
      Fradio,
      Fcheckbox,
      Frate,
      Fswitch,
      Fslider,
      FuploadImg,
      FuploadFile,
      Ftable,
    },
    created() {},
  }
</script>
<style></style>
